//开始按钮控制
cc.Class({
    extends: cc.Component,

    properties: {
        //按钮点击判定[防止多次点击]
        Click_if: {
            default: false,
            visible: false
        },
        //重复重启判定
        Reset_if: {
            default: false,
            visible: false
        }
    },
    // onLoad () {},

    update (dt) {
        if (Game.Reset == true && this.Reset_if == false){
            this.Create_Action("in");
            this.Reset_if = true;
        }
    },

    //按钮回调
    Play_Call () {
        //开始游戏
        if(this.Click_if == false && Game.End == true) {
            Game.End = false;
            this.Click_if = true;
            this.Reset_if = false;
            this.Create_Action("out");
        }
        //重启游戏
        if(this.Reset_if == true && Game.Reset == true) {
            Game.Self.Reset_Game();
            this.Create_Action("out");
            Game.End = false;
            Game.Reset = false;
            this.Reset_if = false;
        }
    },

    //赋予UI整体渐隐渐显出动作
    //type:动作类型
    Create_Action (type) {
        var action = null;
        var func = null;
        if(type == "in") {
            //将UI总节点移出视觉范围
            func = cc.callFunc(function(type){
                Game.UiNode.x = 160;
            },this);
            action = cc.fadeIn(0.5);
            Game.UiNode.runAction(cc.sequence(func,action));
        }

        if(type == "out") {
            //将UI总节点移入视觉范围
            func = cc.callFunc(function(type){
                Game.UiNode.x = -160;
            },this);
            action = cc.fadeOut(0.15);
            Game.UiNode.runAction(cc.sequence(action,func));
        }


    },

});
